package br.mikhas.lab.lang;

import java.util.ArrayList;
import java.util.List;

import br.mikhas.lab.lang.tables.ClassTable;
import br.mikhas.lab.lang.tables.MethodTable;
import br.mikhas.lab.lang.tables.StringTable;

public class Method {

	private final StringTable strings;
	private final Class cls;
	private int name;
	private long offset = 0;
	private int id;
	private List<String> implementation = new ArrayList<String>();

	public Method(StringTable strings, ClassTable classes, MethodTable methods,
			Class cls, String methodName, Class returnType) {
		this.strings = strings;
		this.name = strings.get(methodName);
		this.cls = cls;
		this.id = methods.get(this);
		this.cls.addMethod(this);
	}

	public int getId() {
		return this.id;
	}

	public String getName() {
		return strings.get(this.name);
	}

	public void setOffset(long o) {
		this.offset = o;
	}

	public long getOffset() {
		return this.offset;
	}

	public void addCodeLine(String line) {
		this.implementation.add(line);
	}

	@Override
	public String toString() {
		return "Method[" + this.getId() + ":" + getName() + "]";
	}
}
